<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.lesson.mapper.AppointmentMapper">

    <select id="getList" resultType="com.hzb.erp.api.pc.lesson.pojo.AppointmentVO">
        select t1.id, t1.add_time, t1.student_id, t1.verify_remark, t1.verify_state,
               t1.lesson_id,
               t2.name student_name,
               t5.mobile student_mobile,
               t3.title lesson_title,
               concat(t3.date, ' ', t3.start_time) lesson_time,
               t4.name verify_staff_name
        from appointment t1
        left join student t2 on t2.id = t1.student_id
        left join lesson t3 on t3.id = t1.lesson_id
        left join staff t4 on t4.id = t1.verify_staff
        left join user t5 on t5.id = t2.user_id
        <where>
            <if test="param.studentId != null">
                AND t1.student_id = #{param.studentId}
            </if>
        </where>
        order by t1.id desc
    </select>
</mapper>
